import { Controller, Post, Body } from '@nestjs/common';
import { TestService } from './test.service';
import { CreateTestDto, FindTestDto, UpdateTestDto, RemoveTestDto, CreateBatchTestDto, RemoveBatchTestDto } from './dto/test.dto';
import { useResult } from '@/common/hooks/useResult';
import { Authority } from '@/common/decorators/authority.decorator';

@Controller('test')
export class TestController {
  constructor(private readonly testService: TestService) {}

  @Post('create')
  @Authority()
  async create(@Body() body: CreateTestDto) {
    const res = await this.testService.create(body);
    return useResult(res);
  }

  @Post('findAll')
  @Authority()
  async findAll(@Body() body: FindTestDto) {
    const res = await this.testService.findAll(body);
    return useResult(res);
  }

  @Post('findOne')
  @Authority()
  async findOne(@Body() body: FindTestDto) {
    const res = await this.testService.findOne(body);
    return useResult(res);
  }

  @Post('update')
  @Authority()
  async update(@Body() body: UpdateTestDto) {
    const res = await this.testService.update(body);
    return useResult(res);
  }

  @Post('remove')
  @Authority()
  async remove(@Body() body: RemoveTestDto) {
    const res = await this.testService.remove(body);
    return useResult(res);
  }

  @Post('removeBatch')
  @Authority()
  async removeBatch(@Body() body: RemoveBatchTestDto) {
    const res = await this.testService.removeBatch(body);
    return useResult(res);
  }

  @Post('createBatch')
  @Authority()
  async createBatch(@Body() body: CreateBatchTestDto) {
    const res = await this.testService.createBatch(body);
    return useResult(res);
  }
}
